package com.dyava.commons.clock.mysql;

/**
 * Created by jjliu on 2020/4/18.
 */
public class MysqlClockConstant {
    static String SQL_CREATE =
            "CREATE TABLE IF NOT EXISTS `dy_clock_record` (\n" +
                    "`id`  bigint(20) NOT NULL AUTO_INCREMENT ,\n" +
                    "`handleName`  varchar(128) NOT NULL DEFAULT '' ,\n" +
                    "`args`  varchar(4096) NOT NULL DEFAULT '' ,\n" +
                    "`state`  int(11) NOT NULL DEFAULT 0 COMMENT '0未执行；1执行中；2已完成' ,\n" +
                    "`clockTime`  datetime NOT NULL ,\n" +
                    "`createTime`  datetime NOT NULL ,\n" +
                    "PRIMARY KEY (`id`)\n" +
                    ")\n" +
                    "AUTO_INCREMENT=1\n" +
                    ";\n";

    static String SQL_INSERT =
            "INSERT INTO `dy_clock_record` (`handleName`, `args`, `state`, `clockTime`, `createTime`) " +
                    "VALUES (?, ?, ?, ?, ?);";


    static String SQL_SELECT =
            "SELECT id, handleName, args, state, clockTime, createTime\n" +
                    "FROM\n" +
                    "dy_clock_record where clockTime < NOW() and state=0 LIMIT 100;";

    static String SQL_WORKING =
            "UPDATE `dy_clock_record`\n" +
                    "SET `state` = '1'\n" +
                    "WHERE\n" +
                    "\t`id` = ?;";

    static String SQL_DONE =
            "UPDATE `dy_clock_record`\n" +
                    "SET `state` = '2'\n" +
                    "WHERE\n" +
                    "\t`id` = ?;";

    static String SQL_DELETE =
            "DELETE FROM `dy_clock_record`\n" +
                    "WHERE\n" +
                    "\t`id` = ?;";

}
